from flask import request
from ronglian_sms_sdk import SmsSDK
import json
#封装data
def get_data():
    data = request.data
    if data:
        data = json.loads(data)
    else:
        data = request.form
    return data


#熔炼云发短信
accId = '8a216da87ba59937017bf7ca2e7b1532'
accToken = '125e169d370340f69fdc894315173cc3'
appId = '8a216da87ba59937017bf7ca30571539'


def send_message(mobile,code,time):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    datas = (code, time)
    resp = sdk.sendMessage(tid, mobile, datas)
    result = json.loads(resp)
    if result['statusCode'] == '000000':
        return True
    return False


